#! /bin/bash
# Rebuild the list of security providers in classpath.security

secfiles="/var/lib/security/classpath.security"

for secfile in $secfiles; do
  # check if this classpath.security file exists
  #[ -f "$secfile" ] || continue

  sed '/^security\.provider\./d' /etc/java/security/classpath.security \
      > $secfile

  count=0
  for provider in $(ls /etc/java/security/security.d)
  do
    count=$((count + 1))
    echo "security.provider.${count}=${provider#*-}" >> "$secfile"
  done
done
